<!DOCTYPE html>
<html>
<!--添加进行用户的评论页面信息-->
<head lang="en">
    <title>找攻略</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/js/comment/main.css"/>
    <link rel="stylesheet" type="text/css" href="/js/comment/sinaFaceAndEffec.css"/>
    <link rel="stylesheet" href="/css/strategyComment.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
    <script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
    <script type="text/javascript" src="/js/comment/main.js"></script>
    <script src="/js/comment/sinaFaceAndEffec.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/plugins/chosen/chosen.jquery.js"></script>
    <script>
        $(function () {
            //进行获取到评论id,
            var commentId = getParams().id;
            //console.log(id);
            $.get("/comments/" + commentId + "/particulars", function (data) {
                //console.log(data);
                $(".comment").renderValues({list: data}, {
                    getStar: function (item, value) {
                        var starhtml = '';
                        var unStarhtml = '';
                        var value = parseInt(value);
                        for (var i = 0; i < value; i++) {
                            starhtml += '<i class="fa fa-star"></i>';
                        }
                        for (var i = 0; i < 5 - value; i++) {
                            unStarhtml += '<i class="fa fa-star-o"></i>';
                        }
                        $(item).html(starhtml + unStarhtml);
                    }
                })
                /*//图片的点击事件
                $(".comment-img img").click(function () {
                    $(document).dialog({
                        titleShow: false,
                        overlayClose: true,
                        content: '<div style="text-align: center;"><img width="100%" src="' + $(this).attr('src') + '"></div>'
                    })
                })*/
                //评论框的数据用户信息回显
                //进行评论的操作,数据的操作
                $.get("/comments/" + commentId + "/particulars", function (data) {
                    // console.log(data);
                    //图片的渲染操作
                    $(".col-1").renderValues({list: data});
                });
            })
        });
    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="/index.html">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>点评详情</span>
        </div>
        <div class="col"></div>
    </div>
</div>
<div class="comment">
    <div class="container" render-loop="list">
        <div class="row">
            <div class="col-2 comment-head">
                <a href="userProfiles.html" data-id="43">
                    <img class="rounded-circle" render-src="list.user.headImgUrl">
                </a>
                <button class="btn" id="followBtn"><i class="fa fa-hand-o-right"> </i>关注</button>
            </div>
            <div class="col">
                <span class="comment-star" render-fun="getStar" render-key="list.starNum"></span>

                <span class="comment-date" render-html="list.createTime"></span>
                <div class="comment-content">
                    <p render-html="list.content"></p>
                </div>
                <ul class="comment-img" render-loop="list.imgUrlss">
                    <li>
                        <img render-src="list.imgUrlss.self">
                    </li>
                </ul>
                <div class="comment-link">
                    <a href="strategyCatalogs.html" data-id="2">
                        <img render-src="list.strategy.coverUrl"> <span render-html="list.strategy.title"></span>
                        <i class="fa fa-angle-right fa-2x"></i>
                    </a>
                </div>
            </div>
        </div>
    </div>
    <div class="count d-flex justify-content-between">
        <div class="p-2">评论<span>0</span></div>
        <div class="p-2">赞<span>0</span></div>
    </div>
</div>
<!--添加评论框-->
<div id="content" style="width: 350px; height: auto;">
    <div class="wrap">
        <div class="comment">
            <div class="row">
                <div class="col-1">
                    <div class="head-face" render-loop="list">
                        <img render-src="list.user.headImgUrl" width="30px"><br>
                        <p render-html="list.user.nickName"></p>
                        <div class=""></div>
                    </div>
                    <p render-html="list.user.nickName"></p>
                </div>
                <div class="col-11">
                    <div class="content">
                        <div class="cont-box">
                            <textarea class="text" placeholder="请输入..."></textarea>
                        </div>
                        <div class="tools-box">
                            <div class="operator-box-btn"><span class="face-icon">☺</span><span class="img-icon"></span>
                            </div>
                            <div class="submit-btn"><input type="button" onClick="out()" value="提交评论"/></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="info-show">
            <ul></ul>
        </div>
    </div>
</div>
<div class="comment-list">
    <div class="container">
    </div>
</div>

<div class="operation">
    <div class="d-flex justify-content-between">
        <div class="p-2"><i class="fa fa-commenting-o"></i> 添加你的评论</div>
        <div class="p-2"><i class="fa fa-star-o"></i> 收藏</div>
    </div>
</div>
</body>
<script type="text/javascript">
    var commentId = getParams().id;
    //添加评论信息
    $('.face-icon').SinaEmotion($('.text'));

    // 测试本地解析
    function out() {
        var inputText = $('.text').val();
        $('#info-show ul').append(reply(AnalyticEmotion(inputText)));
    }

    var html;

    function reply(data) {
        html = '<li id="comment">';
        html += '<div class="head-face" render-loop="list">';
        html += '<img src="http://up.qqya.com/allimg/2017-p02/17-122809_11746.jpg" / >';
        html += '</div>';
        html += '<div class="reply-cont">';
        html += '<p class="username" render-html="list.user.nickName">我是谁</p>';
        html += '<p class="comment-body">' + data + '</p>';
        html += '<p class="comment-footer">2019年1月17日　回复　点赞54　转发12</p>';
        html += '</div>';
        html += '</li>';
        return html;
    }

    $.get("/comments/" + commentId + "/particulars", function (data) {
        $("#comment").renderValues({list: data});
    });
</script>
</html>